home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / NeoIntroPP3.0 folder / PowerPlant / NeoBench / Includes / CNeoWindow.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-14  |  3.5 KB  |  116 lines  |  [TEXT/MMCC]

  1. /*****************************************************************
  2.   CNeoWindow.h
  3.  
  4.   Header file for the CNeoWindow class.
  5. *****************************************************************/
  6.  
  7. #ifndef __CNeoWindow__
  8. #define __CNeoWindow__
  9.  
  10. #include <Timer.h>
  11. #include "LWindow.h"
  12. #include "LPeriodical.h"
  13. #include "LListener.h"
  14. #include "NeoBench.h"
  15.  
  16. class CNeoDatabasePP;
  17. class CNeoIndexIterator;
  18. class CRawText;
  19. class LEditField;
  20. class LButton;
  21. class CNeoWindow;
  22. #ifndef qNeoPersist
  23. class CNeoIndexIterator;
  24. #endif
  25.  
  26. #define kTitlePICTID    129
  27.  
  28. #ifdef qNeoThreads
  29. #include CNeoThreadNativeH
  30.  
  31. typedef enum {
  32.     kDie,
  33.     kAlive
  34. } health;
  35.  
  36. #define kMaxThreads        5
  37.  
  38. typedef struct {
  39.     short                phase;        /* Phase of work being done                */
  40.     health                state;        /* Healthiness of this thread            */
  41.     CNeoWindow *        window;        /* Window this thread is working for    */
  42.     CNeoThreadNative *    thread;        /* Pointer to thread                    */
  43. } ThreadInfo;
  44.  
  45. class CBenchThread : public CNeoThreadNative
  46. {
  47. public:
  48.                         CBenchThread(ThreadInfo *aInfo, const NeoThreadType aType = kNeoCoopThread, void **aArg = nil, const Size aStackSize = kNeoDefaultStackSize, const NeoThreadOptions aOptions = (kNeoThreadNewSuspend + kNeoThreadUsePremade + kNeoThreadCreate));
  49.     virtual long        run(void);
  50.  
  51.     virtual void        handleSwapIn(void);
  52.     virtual void        handleSwapOut(void);
  53.  
  54. protected:
  55.     Boolean                fSetTimer;
  56.     TMTask                fTimer;
  57.     ThreadInfo *        fInfo;
  58. };
  59. #endif
  60.  
  61. class CNeoWindow : public LWindow, public LPeriodical, public LListener {
  62. public:
  63.                         CNeoWindow(const ResIDT aResID, CNeoDocPP *aDocument);
  64.     virtual                ~CNeoWindow(void);
  65.  
  66.                         /** Drawing **/
  67.     void                DrawSelf(void);
  68.  
  69.                         /** Statistics **/
  70.     void                checkDatabaseState(void);
  71.     void                ClearStatPanes(void);
  72.     short                getPhase(void) const;
  73.     long                getPhaseTarget(const short aPhase) const;
  74.     Boolean                getState(void) const;
  75.     void                getTargetTotals(void);
  76.     long                GetTotalNum(short index);
  77.     void                setDocument(CNeoDocPP *aDoc);
  78.     void                setPhase(const short aPhase);
  79.     void                setState(const Boolean aState);
  80.     void                UpdateCol(short aPhase, short aRow, long aValue);
  81.  
  82.                         /** Events/Drawing **/
  83.     virtual void        ClickInZoom(const EventRecord& inMacEvent, short inZoomDirection);
  84.     virtual void        doSomeWork(const short aPhase, TMTask *aTimer);
  85.     virtual Boolean        HandleKeyPress(const EventRecord &inKeyEvent);
  86. #ifdef qNeoThreads
  87.     void                killThreads(void);
  88. #endif
  89.     virtual void        ListenToMessage(MessageT aMessage, void *aParam);
  90.     virtual void        SpendTime(const EventRecord &inMacEvent);
  91.  
  92. protected:
  93.     NeoPhase            fPhaseInfo[kMaxPhase +1];    // The main phases
  94.     Boolean                fState;                        // Running state
  95.     Boolean                fRefresh;                    // Update stats on screen
  96.     short                fPhase;                        // The current phase
  97. #ifdef qNeoThreads
  98.     short                fThreadCount;                // Current number of slave threads
  99.     ThreadInfo            fThreadInfo[kMaxThreads];    // Info used by each thread
  100. #endif
  101.     CNeoIndexIterator *    fIterator;                    // For traversing index of objects
  102.     long                col_value[3];                // 3 columns - soFar, PerRecord, Total
  103.     short                col_index;                    // Index into the column
  104.  
  105.     CRawText *            NeoRawTexts[kMaxPhase +1][kMaxCol +1];    // the texts displaying the numbers
  106.     LEditField *        NeoEditTexts[kMaxPhase +1];                // the TOTALS editable texts
  107.     CRawText *            NeoPhaseNames[kMaxPhase +1];            // Phase names
  108.     LButton *            NeoStopButton;                            // Stop button
  109.     LButton *            NeoGoButton;                            // Go button
  110.     CRawText *            fSizeStatic;                            // Object size label
  111.     LEditField *        fSizeText;                                // Object size text
  112.  
  113.     long                maxValue[kMaxPhase +1];
  114.     long                minValue[kMaxPhase +1];
  115. };
  116. #endif